# 构建阶段
FROM maven:3.8.4-openjdk-17 AS builder
WORKDIR /app
COPY pom.xml .
COPY common/ ./common/
COPY user-service/ ./user-service/
COPY gateway-service/ ./gateway-service/
RUN mvn clean package -DskipTests

# 运行阶段
FROM openjdk:17-alpine
WORKDIR /app
COPY --from=builder /app/user-service/target/user-service-1.0.0.jar user-service.jar
COPY --from=builder /app/gateway-service/target/gateway-service-1.0.0.jar gateway-service.jar

# 启动脚本（同时启动多个服务，生产环境建议用 Docker Compose 分开启动）
CMD ["sh", "-c", "java -jar user-service.jar & java -jar gateway-service.jar"]